<?php
    if (!isset($user)) {
        $user['user_login'] = "";
        $user['user_email'] = "";
        $user['user_title'] = "";
        $user['user_id'] = -1;
        $user = (object) $user;
    }
?>
<h3><?=$subtitle?></h3>
<input type="hidden" id="user_id" value="<?=$user->user_id?>"/>

<div class="form_section" id="username_section">
<div class="title">Username: <span class="subtitle">(required)</span></div>
<input type="text" placeholder="Username" id="input_username" value="<?=$user->user_login?>" 
    <?if ($user->user_id > 0) echo "disabled='disabled'"?> class="input_field"/><span id="user_login_check"></span>
<div class="warning_section"></div>
</div>


<div class="form_section" id="email_section">
<div class="title">Email: <span class="subtitle">(required)</span></div>
<input type="text" placeholder="Email" id="input_email" value="<?=$user->user_email?>"  class="input_field"/><span id="user_email_check"></span>
<div class="warning_section"></div>
</div>


<div class="form_section" id="name_section">
<div class="title">Full Name: <span class="subtitle">(required)</span></div>
<input type="text" placeholder="Full Name" id="input_name" value="<?=$user->user_title?>" class="input_field"/>
<div class="warning_section"></div>
</div> 

<?if ($user->user_id == -1 || get_role_num() == admin_role())://If we are creating a new user or we are an admin?>
<div class="form_section" id="requirements_section">
<div class="title">Dietary Requirements: <span class="subtitle">(optional)</span></div>

<select id="requirement_options">
    <option value="-1">- Select Requirements -</option>
    <?foreach($basetypes->result() as $result):?>
    <option value="<?=$result->basetype_id?>"><?=$result->basetype_title?></option>
    <?endforeach;?>
</select>
        
<div class="listbox" id="requirement_list">
    <?if(isset($requirements)):?>
        <?foreach($requirements->result() as $result):?>
            <span class="listboxItem" value="<?=$result->basetype_id?>">
                <label class="listboxItemLabel"><?=$result->basetype_title?></label>
                <a class="listboxItemClose" onclick="listboxRemoveItem(this)"></a>
            </span>
        <?endforeach;?>
    <?endif;?>
</div>
<div class="warning_section"></div>
</div>
<input type='hidden' id="no_requirements" value="0"/>
<?else:?>
<input type='hidden' id="no_requirements" value="1"/>
<?endif;?>

<div class="form_section" id="password_section">
<div class="title">Password: <span class="subtitle">(Will be sent via email)</span></div>
<div id="password_location">
<?if ($user->user_id == -1):?>
    <div id="input_password"><?=$password?></div>
<?else:?>
    <td id="password"><input type="button" id="change_password" class="buttonLight" value="Reset Password"/>
<?endif;?>
</div>
</div>

<div class="form_section" id="button_section">
<input type="button" id="submit_button" class="button" value="<?=$save_text?>" />
<input type="button" id="cancel_button" class="button" value="Cancel Changes" />
</div>
<input type="hidden" id="hidden_pass" value="<?=$password?>"/>
